#!/usr/bin/python

import unittest

from proc import *

class TestExe(unittest.TestCase):
	def testexe(me):
		#simple
		me.assertEquals(exe("python -c \"print 'foo'\""),'foo\n')

		
		#two commands at one
		me.assertEquals(exe("python -c \"print 'foo'\"\n python -c \"print 'bar'\""), 'foo\nbar\n')
		
		#stdin,stderr interspersed
		me.assertEquals(exe("python -c \"import sys; sys.stdout.write('foo '); sys.stdout.flush(); sys.stderr.write('bar '); sys.stdout.write('baz'); sys.stdout.flush();\""),'foo bar baz')
		
		#command exits with error
		me.assertRaises(AssertionError, exe, "python -c \"import sys; sys.exit(1)\"")

		#error command in sequence
		me.assertRaises(AssertionError, exe, "python -c \"print 'foo'\"\n python -c \"import sys; sys.exit(1)\"\n python -c \"print 'bar'\"")

	
if __name__=="__main__":
	print "There'll be some output, that is fine."
	unittest.main()